import copy

class Solution(object):
    def jump(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        ran = [0, 0]
        jmp = 0
        while ran[1]<len(nums)-1:
            nextRan = copy.copy(ran)
            for i in range(ran[0], ran[1]+1):
                far = i + nums[i]
                nextRan[1] = max(nextRan[1], far)
            nextRan[0] = ran[0]+1
            ran = nextRan
            jmp+=1
        return jmp
        

print(Solution().jump([2,3,1,1,4]))